<?php 
if ( ! is_admin() || defined('DOING_AJAX') ) {

	//Xử lý lại breadcrumb cho nó chạy trước action 'woocommerce_output_content_wrapper'
    remove_action( 'woocommerce_before_main_content', 'woocommerce_breadcrumb', 20, 0 );
    add_action( 'mv_breadcrumb', 'woo_breadcrumb', 5, 0 ); // chú ý số 5
    function woo_breadcrumb( $args = array() ) {

		$defaults = array(
			'delimiter'  => ' &rsaquo; ',
			'wrap_before'  => '<div id="breadcrumbs" itemprop="breadcrumb">',
			'wrap_after' => '</div>',
			'before'   => '',
			'after'   => '',
			'home'    => null
		);

		$args = wp_parse_args( $args, $defaults  );

		woocommerce_get_template( 'shop/breadcrumb.php', $args );
	}

	//Action Xử lý kiểm tra xem sản phẩm có được giảm giá hay không
	add_action('mv_product_sale_flash','woocommerce_show_product_loop_sale_flash',10);

} 

add_action( 'woocommerce_after_single_product_summary', 'woocommerce_output_facebook_comment', 12 );

if( !function_exists(woocommerce_output_facebook_comment)){
	function woocommerce_output_facebook_comment()
	{
		$url = current_url(); ?>
		
		<!-- facebook comments -->
		<div id="fb-root"></div>
		<script>(function(d, s, id) {
		  var js, fjs = d.getElementsByTagName(s)[0];
		  if (d.getElementById(id)) return;
		  js = d.createElement(s); js.id = id;
		  js.src = "//connect.facebook.net/en_US/all.js#xfbml=1&appId=161009240647765";
		  fjs.parentNode.insertBefore(js, fjs);
		}(document, 'script', 'facebook-jssdk'));</script>

		<div class="fb-comments" data-href="<?php echo $url;?>" data-width="670" data-num-posts="2"></div>
		<!-- end facebook comments -->

	<?php		
	}
}

?>
